package Day0506;

public class Test {
    public static void main(String[] args) {
        Graphic[] arr=new Graphic[4];
        Rectangle r1=new Rectangle();
        r1.setLength(5);
        r1.setWidth(2);
        arr[0]=r1;

        Rectangle r2=new Rectangle();
        r2.setLength(4);
        r2.setWidth(3);
        arr[1]=r2;

        Circle c1=new Circle();
        c1.setRadius(2);
        arr[2]=c1;

        Circle c2=new Circle();
        c1.setRadius(1);
        arr[3]=c1;

        for (int i = 1; i < arr.length ; i++) {
            System.out.println(arr[i].getInfo());

        }
        for (int i = 1; i < arr.length ; i++) {
            for (int j = 0; j < arr.length-i; j++) {
                if(arr[j].area()>arr[j+1].area()){
                    Graphic tmp=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=tmp;
                }

            }

        }
        for (int i = 0; i < arr.length ; i++) {
            System.out.println(arr[i].getInfo());

        }

    }
}
